package com.kgar.controller;


import com.kgar.dto.Result;
import com.kgar.service.UploadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * @author Trimb
 */
@Slf4j
@RestController
@RequestMapping("/upload")
public class UploadController {

    @Resource
    private UploadService uploadService;

    @PostMapping("image")
    public Result uploadImage(@RequestParam("file") MultipartFile image) {
        return uploadService.uploadImage(image);
    }

    @PostMapping("resume")
    public Result uploadResume(@RequestParam("file") MultipartFile resume){
        return uploadService.uploadResume(resume);
    }

    /**
     * 批量删除文件
     */
    @DeleteMapping
    public Result deleteFileByBatch(@RequestBody Map<String,List<String>> fileUrls) {
        return uploadService.deleteFile(fileUrls);
    }
}
